﻿// -----------------------------------------------------------------------
// <copyright file="Errors.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace BasicFrameworkDemo.Utility
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Xml;
    using System.Configuration;

    /// <summary>
    /// TODO: Update summary.
    /// </summary>
    public class SystemOperations
    {   
        /// <summary>
        /// Configs this instance.
        /// </summary>
        /// Creator:LiLei
        /// CreationDate:7/9/2012 4:55 PM
        /// Modify:
        /// ModifyDate:
        /// ----------------------------------------------------------------------------------------
        public Dictionary<string, string> Config()
        {
            var operationsDictionary = new Dictionary<string, string>();
            var xmlDoc = new XmlDocument();
            xmlDoc.Load(string.Format("{0}/{1}", AppDomain.CurrentDomain.BaseDirectory, SystemConfig.OperationsConfigPath));

            var xmlParent = xmlDoc.SelectSingleNode(SystemConfig.OperationsConfigRootName);
            if (xmlParent == null)
            {
                return new Dictionary<string, string>();
            }

            var childNodes = xmlParent.ChildNodes;

            return childNodes.Cast<XmlNode>().ToDictionary(childNode => childNode.ChildNodes[0].InnerText, childNode => childNode.ChildNodes[1].InnerText);
        }

    }
}
